package com.atguigu.springcloud.controller;

import com.atguigu.springcloud.service.PaymentHystrixBreakerService;
import com.atguigu.springcloud.service.PaymentHystrixService;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author daiyongfei
 * <p>
 * 熔断
 */
@RestController
@Slf4j
public class OrderHystrixBreakerController {

    @Resource
    private PaymentHystrixBreakerService paymentHystrixBreakerService;


    /**
     * 服务熔断
     *
     * @param id
     * @return
     */
    @GetMapping("/payment/circuit/{id}")
    public String paymentCircuitBreaker(@PathVariable("id") Integer id) {
        String result = paymentHystrixBreakerService.paymentCircuitBreaker(id);
        log.info("****result: " + result);
        return result;
    }

}
